<template>
  <view>
<!--    <cu-custom bgColor="bg-yellow" :isBack="true"><block slot="backText">返回</block>-->
<!--      <block slot="content">报表</block>-->
<!--    </cu-custom>-->


    <view class="charts-box">
      <qiun-data-charts type="column" :chartData="chartData" />
    </view>
  </view>
</template>

<script setup lang="ts">

import {onMounted, computed, reactive, ref} from 'vue'
import {onLoad, onReady, onShow} from '@dcloudio/uni-app';
import {redirectLoginPage} from '@/common/utils/redirectPage'

import {useStore} from "@/common/store";
const store = useStore();

const token = computed(() => store.token)
const userId = computed(() => store.userId)

const chartData = ref({})

const getServerData =() => {
  //模拟从服务器获取数据时的延时
  setTimeout(() => {
    let res = {
      categories: ["2016", "2017", "2018", "2019", "2020", "2021"],
      series: [
        {
          name: "目标值",
          data: [35, 36, 31, 33, 13, 34]
        },
        {
          name: "完成量",
          data: [18, 27, 21, 24, 6, 28]
        }
      ]
    };
    chartData.value = JSON.parse(JSON.stringify(res));
  }, 500);
}

onShow(() => {
  if ((!userId.value) || userId.value == 0) {
    redirectLoginPage(false, '/pages/home/index');
  }
  getServerData();
})

onMounted(() => {
})
</script>

<style scoped>

.charts-box {
  width: 100%;
  height: 300px;
}
</style>
